//
//  ProductInfomationViewCell.m
//  MyNewProject
//
//  Created by ZhangYuan on 2019/1/28.
//  Copyright © 2019年 sun. All rights reserved.
//

#import "ProductInfomationViewCell.h"
#import "XMJSWebViewController.h"
@implementation ProductInfomationViewCell
- (nonnull instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(nullable NSString *)reuseIdentifier type:(NSInteger)type
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self addSubview:self.productName];
        [self addSubview:self.timeLabel];

        if (type<5) {
            UIView * lineView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 10)];
            lineView.backgroundColor = BackColor;
            [self.bottomView addSubview:lineView];
            [self addSubview:self.bottomView];
            if (type == 4) {//已成交
                [self.bottomView addSubview:self.userHeadImg];
                [self.bottomView addSubview:self.username];

                [self.bottomView addSubview:self.contentLab];
                [self.bottomView addSubview:self.tipImage];
            }else{
                [self.bottomView addSubview:self.theNewPrice];
                [self.bottomView addSubview:self.theNewPriceTips];

                [self.bottomView addSubview:self.lowPrice];
                self.lowPrice.userInteractionEnabled = YES;

                [self.bottomView addSubview:self.lowPriceTips];
                self.lowPriceTips.userInteractionEnabled = YES;

                UITapGestureRecognizer *doubleTapGestureRecognizer = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(singleTap:)];

                [doubleTapGestureRecognizer setNumberOfTapsRequired:1];

                [self.lowPriceTips addGestureRecognizer:doubleTapGestureRecognizer];
                [self.lowPrice addGestureRecognizer:doubleTapGestureRecognizer];

                [self.bottomView addSubview:self.addPrice];
                [self.bottomView addSubview:self.addPriceTips];
            }
        }
    }
    return self;
}
- (void)singleTap:(UIGestureRecognizer*)gestureRecognizer

{
    //    TODO:待处理

    NSLog(@"-----singleTap-----");
    [SVProgressHUD show];
    [YQNetworking postWithUrl:@"Index/getNotice" refreshRequest:YES cache:NO params:@{@"type":@(9)} progressBlock:^(int64_t bytesRead, int64_t totalBytes) {

    } successBlock:^(id response) {
        [SVProgressHUD dismiss];
        XMJSWebViewController * webVC = [[XMJSWebViewController alloc]init];
        webVC.type = WebType_H5_content;
        webVC.titleString = @"保证金";
        webVC.fileUrl = SafeString(response[@"data"][0][@"contents"]);
        [[CommonToolHelper shareInstance].currentVC.navigationController  pushViewController:webVC animated:YES];

    } failBlock:^(NSError *error) {
        [SVProgressHUD dismiss];
    }];

}
-(UIImageView *)userHeadImg{
    if (!_userHeadImg) {
        _userHeadImg = [[UIImageView alloc]initWithFrame:CGRectMake(20, 20, 40, 40)];
        _userHeadImg.image = [UIImage imageNamed:@"DefaultHead"];
        _userHeadImg.layer.cornerRadius = 20;
        _userHeadImg.clipsToBounds = YES;
    }
    return _userHeadImg;
}
-(UILabel *)username{
    if (!_username) {
        _username = [[UILabel alloc]initWithFrame:CGRectMake(80, 20, SCREEN_WIDTH - 20, 20)];
        _username.textColor = [UIColor darkGrayColor];
        _username.text = @"用户名称";
        _username.font = [UIFont systemFontOfSize:14];
    }
    return _username;
}
-(UILabel *)contentLab{
    if (!_contentLab) {
        _contentLab = [[UILabel alloc]initWithFrame:CGRectMake(80, 40, SCREEN_WIDTH - 20, 20)];
        _contentLab.text = @"出价1000万，竞拍成功";
        _contentLab.textColor = [UIColor darkGrayColor];
        _contentLab.font = [UIFont systemFontOfSize:14];
    }
    return _contentLab;
}
-(UIImageView *)tipImage{
    if (!_tipImage) {
        _tipImage = [[UIImageView alloc]initWithFrame:CGRectMake(SCREEN_WIDTH - 60, 15, 50, 50)];
        _tipImage.image = [UIImage imageNamed:@"auctionSuccess"];
    }
    return _tipImage;
}
-(UIView *)bottomView{
    if (!_bottomView) {
        _bottomView = [[UIView alloc]initWithFrame:CGRectMake(0, 60, SCREEN_WIDTH, 70)];
        _bottomView.backgroundColor = [UIColor whiteColor];
    }
    return _bottomView;
}
-(UILabel *)timeLabel{
    if (!_timeLabel) {
        _timeLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 30, SCREEN_WIDTH - 20, 25)];
        _timeLabel.textColor = [UIColor darkGrayColor];
        _timeLabel.font = [UIFont systemFontOfSize:13];
    }
    return _timeLabel;
}
-(UILabel *)productName{
    if (!_productName) {
        _productName = [[UILabel alloc]initWithFrame:CGRectMake(10,5, SCREEN_WIDTH - 20, 25)];
        _productName.textColor = [UIColor darkTextColor];
        _productName.font = [UIFont systemFontOfSize:15];
    }
    return _productName;
}

-(UILabel *)theNewPrice{
    if (!_theNewPrice) {
        _theNewPrice = [[UILabel alloc]initWithFrame:CGRectMake(0,20, SCREEN_WIDTH/3.0, 20)];
        _theNewPrice.textColor = [UIColor redColor];
        _theNewPrice.textAlignment = NSTextAlignmentCenter;
        _theNewPrice.font = [UIFont systemFontOfSize:14];
    }
    return _theNewPrice;
}
-(UILabel *)theNewPriceTips{
    if (!_theNewPriceTips) {
        _theNewPriceTips = [[UILabel alloc]initWithFrame:CGRectMake(0,40, SCREEN_WIDTH/3.0, 20)];
        _theNewPriceTips.textColor = [UIColor darkGrayColor];
        _theNewPriceTips.textAlignment = NSTextAlignmentCenter;
        _theNewPriceTips.font = [UIFont systemFontOfSize:14];
        _theNewPriceTips.text = @"最新价";
    }
    return _theNewPriceTips;
}

-(UILabel *)lowPrice{
    if (!_lowPrice) {
        _lowPrice = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/3.0,20, SCREEN_WIDTH/3.0, 20)];
        _lowPrice.textColor = [UIColor darkTextColor];
        _lowPrice.textAlignment = NSTextAlignmentCenter;
        _lowPrice.font = [UIFont systemFontOfSize:14];
    }
    return _lowPrice;
}
-(UILabel *)lowPriceTips{
    if (!_lowPriceTips) {
        _lowPriceTips = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/3.0,40,SCREEN_WIDTH/3.0, 20)];
        _lowPriceTips.textColor = [UIColor darkGrayColor];
        _lowPriceTips.textAlignment = NSTextAlignmentCenter;
        _lowPriceTips.font = [UIFont systemFontOfSize:14];
        _lowPriceTips.text = @"保证金";
    }
    return _lowPriceTips;
}

-(UILabel *)addPrice{
    if (!_addPrice) {
        _addPrice = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH*2/3.0,20, SCREEN_WIDTH/3.0, 20)];
        _addPrice.textColor = [UIColor darkGrayColor];
        _addPrice.textAlignment = NSTextAlignmentCenter;
        _addPrice.font = [UIFont systemFontOfSize:14];
    }
    return _addPrice;
}
-(UILabel *)addPriceTips{
    if (!_addPriceTips) {
        _addPriceTips = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH*2/3.0,40, SCREEN_WIDTH/3.0, 20)];
        _addPriceTips.textColor = [UIColor darkGrayColor];
        _addPriceTips.font = [UIFont systemFontOfSize:14];
        _addPriceTips.textAlignment = NSTextAlignmentCenter;
        _addPriceTips.text = @"加价幅度";
    }
    return _addPriceTips;
}
@end
